<?php

namespace app\agent\validate;

use think\Validate;

class Channel extends Validate
{
    protected $rule = [
        'name' => 'require|alphaNum|min:3|max:20',
        'mobile_discount_slow' => 'require|require|regex:\d{2,3}([.]{1}[0-9]{1,2})?|egt:90|elt:130',
        'mobile_discount_fast' => 'require|require|regex:\d{2,3}([.]{1}[0-9]{1,2})?|egt:90|elt:130',
        'mobile_status_slow' => 'require|in:1,2',
        'mobile_status_fast' => 'require|in:1,2',
        'remark' => 'max:50'
    ];

    protected $message = [
        'name.require' => '请填写渠道名称',
        'name.alphaNum' => '渠道名称只能是字母和数字组成',
        'name.min' => '渠道名称至少 3 个字符',
        'name.max' => '渠道名称最多 20 个字符',
        'mobile_discount_slow.require' => '慢充折扣不能为空',
        'mobile_discount_slow.regex' => '慢充折扣范围：90.00 ~ 130.00',
        'mobile_discount_slow.egt' => '慢充折扣范围：90.00 ~ 130.00',
        'mobile_discount_slow.elt' => '慢充折扣范围：90.00 ~ 130.00',
        'mobile_status_slow.require' => '请选择慢充折扣状态',
        'mobile_status_slow.in' => '慢充折扣状态有误',
        'mobile_discount_fast.require' => '快充折扣不能为空',
        'mobile_discount_fast.regex' => '快充折扣范围：90.00 ~ 130.00',
        'mobile_discount_fast.egt' => '快充折扣范围：90.00 ~ 130.00',
        'mobile_discount_fast.elt' => '快充折扣范围：90.00 ~ 130.00',
        'mobile_status_fast.require' => '请选择快充折扣状态',
        'mobile_status_fast.in' => '快充折扣状态有误',
        'remark.max' => '渠道备注最多 50 个字符',
    ];

    protected $scene = [
        'create' => [
            'name',
            'mobile_discount_slow',
            'mobile_discount_fast',
            'mobile_status_slow',
            'mobile_status_fast',
            'remark',
        ],
        'edit' => [
            'id',
            'mobile_discount_slow',
            'mobile_discount_fast',
            'mobile_status_slow',
            'mobile_status_fast',
            'remark',
        ],
    ];
}
